package com.qf.index.gcrdo.httpclient;


import org.apache.commons.lang.StringUtils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class LogWriteUtil {
    public static void WriteLog(String LogInfo, String threadid) {
        String path = "D://avParselog/";
        File file = new File(path);
        if (!file.exists()) {
            file.mkdir();
        }
        String FileName = "";
        if (StringUtils.isNotEmpty(threadid)) {
            FileName = path + new SimpleDateFormat("yyyyMMdd").format(new Date()) + "_" + threadid + ".txt";

        } else {
            FileName = path + new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".txt";

        }
        FileWriter fileWritter;
        try {
//				SmallTool.printMess(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "：" + LogInfo + "【第" + (threadid + 1) + "线程】");
            fileWritter = new FileWriter(FileName, true);
            BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
            bufferWritter.write(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "：" + LogInfo + "\r\n");
            bufferWritter.close();
        } catch (IOException e) {
            SmallTool.printMessError("异常信息++" + e.getMessage());
        }
    }

    public static void WriteLogAVDOWN(String LogInfo) {
        String path = "/usr/logs/avdown/";
        File file = new File(path);
        if (!file.exists()) {
            file.mkdir();
        }
        String FileName = path + new SimpleDateFormat("yyyyMMddHH").format(new Date()) + ".txt";

        FileWriter fileWritter;
        try {
            fileWritter = new FileWriter(FileName, true);
            BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
            bufferWritter.write(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ":" + LogInfo.trim() + "\r\n");
            bufferWritter.close();
        } catch (IOException e) {
            SmallTool.printMessError("异常信息++" + e.getMessage());
        }
    }

}


